home *** CD-ROM | disk | FTP | other *** search
- Path: news.iconn.net!news
- From: thecrow@iconn.net (The Crow)
- Newsgroups: comp.lang.c++
- Subject: Re: Arrays-What are they good for?
- Date: 2 Jan 1996 02:46:03 GMT
- Organization: I rule the world
- Message-ID: <4ca69b$1o1@news.iconn.net>
- References: <4c6fc5$jv3$1@mhadf.production.compuserve.com>
- NNTP-Posting-Host: st-ts00-02.iconn.net
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.6
-
- In article <4c6fc5$jv3$1@mhadf.production.compuserve.com>,
- 71702.1123@CompuServe.COM says...
- >
- >
- >Hello all....
- >
- >What are arrays? After reading about them countless times I cannot understand
- >their purpose nor how to use them. Can someone give me an example showing how
- >they can be used? Thank you..
- >Merlin
-
- Say you want to read 16384 bytes of a file into memory, then manipulate it a
- little bit. Rather than have 16384 different variable that you could never keep
- track of, you just
-
- int FBlock[16383];
-
- and you can read all the bytes of the file into memory with a simple loop
-
- For(i=0;i<16384;i++)
- {
- read in the byte here
- }
- and all the bytes will be stored in one variable, nice an neat, and you can
- access any one of those bytes quickly. Say you want the 10th one, just say
-
- a = FBlock[9]; // it starts with 0 so 9 is the 10th
-
- you dont HAVE to use variable, but the only alternative is having 100 pages of
- code and 1000's of different variable names which just isnt anyones idea of a
- good time.
-
-
- --
- The Crow - thecrow@iconn.net
- "It can't rain all the time"
- -Kryptology
-
-